<template>
    <div class="picture">
        <el-upload
            ref="upload"
            class="upload-demo"
            drag
            headers="{'Content-Type': 'multipart/form-data'}"
            action="http://localhost:3007/api/upload"
            :auto-upload="false"
            :multiple="false"
            :on-success="handleSuccess"  
            :before-upload="beforeUpload" 
            :data={url:url,school_id:form.school_id}
        >
            <i class="el-icon-upload"></i>
            <div class="el-upload__text">
                将文件拖到此处，或<em>点击上传</em>
            </div>
        </el-upload>
    </div>
</template>

<script setup>


 function beforeUpload(file) {  
                const isJPG = file.type === 'image/jpeg';  
                const isLt2M = file.size / 1024 / 1024 < 2;  
            
                if (!isJPG) {  
                    Message.error('上传图片只能是 JPG 格式!');  
                }  
                if (!isLt2M) {  
                    Message.error('上传图片大小不能超过 2MB!');  
                }  
                return isJPG && isLt2M;  
            }  
            // 上传成功
  function handleSuccess(response, file, fileList) {  
      Message.success('上传成功'); 
    //   this.getSchoolInfo() 
  }

</script>

<style lang="less" scoped>


</style>